<?php

namespace Modules\Edu\Http\Controllers\Member;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Notifications\Notification;
use Illuminate\Routing\Controller;

class MessageController extends Controller
{

    public function index()
    {
        $notifications = user()->make()->unreadNotifications()->paginate();
        return view('edu::member.message',compact('notifications'));
    }

    public function show($message)
    {

        $notification = user()->make()->notifications()->where('id', $message)->first();
        $notification->markAsRead();
        return redirect($notification->data['action']);
    }
    public function destroy($message)
    {
        user()->make()->notifications()->where('id', $message)->delete();
        return response()->json(['message'=>'删除成功']);
    }
}
